import { routerHandleReturn } from "../type";
import { Op } from "sequelize";
import { article, findtitlelimit } from "../interface";
import Comment from "../model/Comment";

export default {
  async getall() {
    const result = await Comment.findAndCountAll();
    return result;
  },
  async submit(data: object) {
    const result = await Comment.create(data as any);
    if (!result) return result;
    return result.toJSON();
  },
  async findpk(id: number) {
    const result = await Comment.findByPk(id);
    if (!result) return null;
    return result.toJSON();
  },
  async update(data: object, id: number) {
    const [result] = await Comment.update(data, { where: { id } });
    return result;
  },
};
